﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            Stack stack = new Stack();
            stack.Push(1);  //添加元素
            stack.Peek(); //获取栈顶元素的值，但不移除栈顶元素的值
            stack.Pop();  //移除栈顶元素的值，并移除栈顶元素
            stack.Clear(); //清空


            Console.WriteLine(stack.Contains(1));//判断元素是否存在

            object[] a = stack.ToArray();//复制到数组a上

            Stack stack1 = new Stack();

            stack1.Push(1001);
            stack1.Push(1002);
            stack1.Push(1003);
            stack1.Push(1004);
            Console.WriteLine("取票:");
            // //判断栈中是否有元素
            while(stack1.Count!=0)
            {
                //取出元素
                Console.WriteLine(stack1.Pop());
            }
        }
    }
}
